<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Axios</title>
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
      integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu"
      crossorigin="anonymous"
    />
    <script
      crossorigin="anonymous"
      src="https://cdn.bootcdn.net/ajax/libs/axios/1.1.3/axios.js"
    ></script>
  </head>
  <body>
    <div class="container">
      <h2 class="page-header">JQuery发起AJAX请求</h2>
      <button class="btn btn-primary">GET</button>
      <button class="btn btn-danger">POST</button>
      <button class="btn btn-info">通用型方法ajax</button>
    </div>
    <script>
      const btns = document.getElementsByTagName("button");
      axios.defaults.baseURL = "http://127.0.0.1:8000";
      btns[0].onclick = function () {
        axios
          .get("/axios-server", {
            params: {
              name: "123",
            },
            Headers: {
              name: "11",
            },
          })
          .then((value) => {
            console.log(value);
          });
      };
    </script>
  </body>
</html>
